package com.sxz.sbs.module.client.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sxz.sbs.R;
import com.sxz.sbs.module.client.bean.BuildingBean;
import java.util.List;

/**
 * 所有楼盘适配器
 * @author hp
 */

public class BuildingAdapter extends BaseQuickAdapter<BuildingBean.ListBean,BuildingAdapter.ViewHolder>{


    private OnShowItemClickListener onShowItemClickListener;

    public BuildingAdapter(@Nullable List<BuildingBean.ListBean> data) {
        super(R.layout.item_building,data);
    }

    @Override
    protected void convert(final ViewHolder helper, final BuildingBean.ListBean item) {

        helper.setText(R.id.title,item.getTxt_BuildNum());
        helper.setText(R.id.tv_principal,item.getTxtName());
        if (item.getIsContains()==1){
            item.setChecked(true);
        }else if (item.getIsContains()==2) {
            item.setChecked(false);
        }
        //监听后设置选择状态
        helper.checkBox.setChecked(item.isChecked());
    }

    class ViewHolder extends BaseViewHolder{
        CheckBox checkBox;
        public ViewHolder(View view) {
            super(view);
            checkBox =view.findViewById(R.id.checkBox1);
        }
    }

    public interface OnShowItemClickListener {
        public void onShowItemClick(BuildingBean.ListBean bean, int i);
    }
    public void setOnShowItemClickListener(OnShowItemClickListener onShowItemClickListener) {
        this.onShowItemClickListener = onShowItemClickListener;
    }
}
